<template>
<!-- 这是所有商家列表 -->
  <div>
    <div style="max-width:1150px;width:1150px;margin:10px auto;">
      <el-input placeholder="请输入内容" v-model="input3" class="input-with-select">
        <el-select v-model="select" slot="prepend" placeholder="请选择">
          <el-option label="账号" value="merchantName"></el-option>
          <el-option label="昵称" value="susuperadmin"></el-option>
          <el-option label="手机号" value="phone"></el-option>
          <el-option label="状态" value="bool"></el-option>
        </el-select>
        <el-button slot="append" icon="el-icon-search" @click="search(select,input3)"></el-button>
      </el-input>
    </div>
    <el-table :data="merchant" stripe style="max-width:1150px;width:1150px;margin:0px auto;">
      <el-table-column prop="_id" label="商家ID" width="220"></el-table-column>
      <el-table-column prop="merchantName" label="账号" width="180"></el-table-column>
      <el-table-column prop="merchantSusuper" label="昵称" width="180"></el-table-column>
      <el-table-column prop="phone" label="手机号" width="180"></el-table-column>
      <el-table-column prop="bool" label="状态" width="180"></el-table-column>
      <el-table-column label="操作" style="display:flex">
        <template slot-scope="scope">
          <el-button size="mini" @click="freezeMerchant(scope.row._id)">是否冻结商家</el-button>
        </template>
      </el-table-column>
    </el-table>
    <div class="block">
      <el-pagination layout="prev, pager, next" :total="num" @prev-click="pre" @next-click="next"></el-pagination>
    </div>
  </div>
</template>

<script>
const axios = require("axios");
export default {
  created() {
    this.pAdminList()
  },
  data() {
    return {
      merchant: [
      ],
        select:'',
        input3:'',
      param:{
        selectType:'',
        inputValue:'',
        pageNum:4, 
        currentPage:1
      },
      total:0,
      num:0
    };
  },
  methods: {
    async pAdminList() {
      //  axios.get("/pAdmins/pAdmin").then(({data})=>{
      //   console.info(data)
      // })
      this.param.selectType=this.select
      this.param.inputValue = this.input3
      let { data } = await axios.get("/pAdmins/pAdmin",{params:this.param})
       data.rows.filter(function(item) {
        if (item.bool===true) {
          item.bool = "未冻结";
        } else {
          item.bool = "已冻结";
        }
      });
      this.merchant = data.rows;
      this.total = data.total;
      this.num = Math.ceil(this.total / this.param.pageNum) * 10;
    },
    freezeMerchant(_id){
      this.$router.push(`/admin/adminIndex/freezeMerchant/${_id}`)
    },
   search() {
      this.pAdminList();
    },
    pre() {
      this.param.currentPage = this.param.currentPage-1;
      console.info(this.param.currentPage);
      this.pAdminList()
    },
    next(){
      this.param.currentPage = this.param.currentPage+1;
      this.pAdminList()
    },
  }
};
</script>

<style>
.el-table td,
.el-table th {
  text-align: center !important;
}
.el-select .el-input {
  width: 130px;
}
.input-with-select .el-input-group__prepend {
  background-color: #fff;
}
.el-main {
  line-height: normal;
}
.cell {
  display: flex;
}
</style>